if exists (select * from dbo.sysobjects where name='sp_AddSinhVien')
begin
	Drop Proc sp_AddSinhVien
end
go
create proc sp_AddSinhVien
@HOTEN VARCHAR(40),
@NGAYSINH VARCHAR(40),
@GIOITINH VARCHAR(40),
@DIACHI VARCHAR(40),
@DIENTHOAI INT,
@EMAIL VARCHAR(40),
@CMND INT,
@TENLOP VARCHAR(40),
@MA_TV INT,
@MA_LOP INT,
@KQ INT OUTPUT
as 
begin 
	SET @KQ=0
	IF NOT EXISTS (SELECT * FROM SINHVIEN WHERE CMND=@CMND)
	BEGIN
		INSERT INTO SINHVIEN VALUES(@HOTEN,@NGAYSINH,@GIOITINH,@DIACHI,@DIENTHOAI,@EMAIL,@CMND,@TENLOP,@MA_TV,@MA_LOP)
		SET @KQ=1
	END
END

DECLARE @KQ INT
EXEC sp_AddSinhVien 'trieuhung','12/20/1990','nam','asdsa','114','sadsad','1251251','laptrinh','2','3',@KQ OUTPUT
SELECT @KQ AS KQ

